import Vue from 'vue'
import VueI18n from 'vue-i18n'
import enUS from 'vant/es/locale/lang/en-US';
import zhCN from 'vant/es/locale/lang/zh-CN';
import { Locale } from 'vant';
// 语言引用
import enUSLocale from './en-US.json'
import zhLocale from './zh-CN.json'

Vue.use(VueI18n)

const i18n = new VueI18n({
  locale: localStorage.getItem("contract-tenant-h5-lang") || "zh-CN", // NOTE: 此处初始化可通过读取 localStorage 中数据
  messages: {
    'zh-CN': {
      ...zhLocale,
    },
    'en-US': {
      ...enUSLocale,
    },
  },
})

const lang = localStorage.getItem("contract-tenant-h5-lang") || "zh-CN";
if (lang === "en-US") {
  Locale.use('en-US', enUS);
} else {
  Locale.use('zh-CN', zhCN);
}

export default i18n
